﻿function Js_Page_Load() {
    InitJQTabs();
    setTimeout('InitTinyMCE()', 1000);
}

function InitJQTabs() {
    $("#tabs").tabs();

    $("#LimitPasses").change(function () {
        if ($(this).attr('checked') == 'checked')
            $("#limitOptions").show();
        else
            $("#limitOptions").hide();
    });

    $("#BundlePasses").change(function () {
        if ($(this).attr('checked') == 'checked')
            $("#bundleOptions").show();
        else
            $("#bundleOptions").hide();
    });

    $("#ResetLimit").change(function () {
        if ($(this).attr('checked') == 'checked')
            $("#LimitPeriodType").show();
        else
            $("#LimitPeriodType").hide();
    });

    $("#ResetBundle").change(function () {
        if ($(this).attr('checked') == 'checked')
            $("#BundlePeriodType").show();
        else
            $("#BundlePeriodType").hide();
    });
}

function fixTinyMCE() {
    tinyMCE.execCommand('mceAddControl', false, 'WelcomeTextPL');
    tinyMCE.execCommand('mceAddControl', false, 'WelcomeTextENG');

    tinyMCE.execCommand('mceAddControl', false, 'InfoTextPL');
    tinyMCE.execCommand('mceAddControl', false, 'InfoTextENG');

    tinyMCE.execCommand('mceAddControl', false, 'SummaryTextPL');
    tinyMCE.execCommand('mceAddControl', false, 'SummaryTextENG');

    tinyMCE.execCommand('mceAddControl', false, 'BlockTextPL');
    tinyMCE.execCommand('mceAddControl', false, 'BlockTextENG');

    //zakładka treści maili
    tinyMCE.execCommand('mceAddControl', false, 'OpenInfoMailTextPL');
    tinyMCE.execCommand('mceAddControl', false, 'OpenInfoMailTextENG');
    tinyMCE.execCommand('mceAddControl', false, 'PasswordChangeMailTextPL');
    tinyMCE.execCommand('mceAddControl', false, 'PasswordChangeMailTextENG');
    tinyMCE.execCommand('mceAddControl', false, 'ConfirmUpMailTextPL');
    tinyMCE.execCommand('mceAddControl', false, 'ConfirmUpMailTextENG');
    tinyMCE.execCommand('mceAddControl', false, 'ConfirmDownMailTextPL');
    tinyMCE.execCommand('mceAddControl', false, 'ConfirmDownMailTextENG');
    tinyMCE.execCommand('mceAddControl', false, 'DeactivationMultisportMailTextPL');
    tinyMCE.execCommand('mceAddControl', false, 'DeactivationMultisportMailTextENG');
    tinyMCE.execCommand('mceAddControl', false, 'RemindMailTextPL');
    tinyMCE.execCommand('mceAddControl', false, 'RemindMailTextENG');

    tinyMCE.execCommand('mceAddControl', false, 's_OrderUpdateUpMailTextPL');
    tinyMCE.execCommand('mceAddControl', false, 's_OrderUpdateUpMailTextENG');
    tinyMCE.execCommand('mceAddControl', false, 's_OrderUpdateDownMailTextPL');
    tinyMCE.execCommand('mceAddControl', false, 's_OrderUpdateDownMailTextENG');
    tinyMCE.execCommand('mceAddControl', false, 's_OrderResignMailTextPL');
    tinyMCE.execCommand('mceAddControl', false, 's_OrderResignMailTextENG');
}

function InitTinyMCE() {
    initAdvancedEditor('textarea#WelcomeTextPL');
    initAdvancedEditor('textarea#WelcomeTextENG');
    initAdvancedEditor('textarea#InfoTextPL');
    initAdvancedEditor('textarea#InfoTextENG');
    initAdvancedEditor('textarea#SummaryTextPL');
    initAdvancedEditor('textarea#SummaryTextENG');
    initAdvancedEditor('textarea#BlockTextPL');
    initAdvancedEditor('textarea#BlockTextENG');
    initAdvancedEditor('textarea#SurveyStaticText');

    //zakładka treści maili
    initAdvancedEditor('textarea#OpenInfoMailTextPL');
    initAdvancedEditor('textarea#OpenInfoMailTextENG');
    initAdvancedEditor('textarea#PasswordChangeMailTextPL');
    initAdvancedEditor('textarea#PasswordChangeMailTextENG');
    initAdvancedEditor('textarea#ConfirmUpMailTextPL');
    initAdvancedEditor('textarea#ConfirmUpMailTextENG');
    initAdvancedEditor('textarea#ConfirmDownMailTextPL');
    initAdvancedEditor('textarea#ConfirmDownMailTextENG');
    initAdvancedEditor('textarea#DeactivationMultisportMailTextPL');
    initAdvancedEditor('textarea#DeactivationMultisportMailTextENG');
    initAdvancedEditor('textarea#RemindMailTextPL');
    initAdvancedEditor('textarea#RemindMailTextENG');

    initAdvancedEditor('textarea#s_OrderUpdateUpMailTextPL');
    initAdvancedEditor('textarea#s_OrderUpdateUpMailTextENG');
    initAdvancedEditor('textarea#s_OrderUpdateDownMailTextPL');
    initAdvancedEditor('textarea#s_OrderUpdateDownMailTextENG');
    initAdvancedEditor('textarea#s_OrderResignMailTextPL');
    initAdvancedEditor('textarea#s_OrderResignMailTextENG');
}

function reloadGraphicPanel(url, panelId) {
    if (panelId != '-1') {
        $.post(url, { panelId: panelId }, function (data) {
            $("#LayoutName").val(data["LayoutName"]);
            if (data["IsWideSiteDisposition"] == true) {
                $('#IsWideSiteDisposition:eq(1)').attr('checked', 'checked');
            }
            else {
                $('#IsWideSiteDisposition:eq(0)').attr('checked', 'checked');
            }
            $("#ForegroundColor").val(data["ForegroundColor"]);
            $("#ForegroundColor").trigger("focus");
            $("#ForegroundColor").trigger("blur");
            $("#BackgroundColor").val(data["BackgroundColor"]);
            $("#BackgroundColor").trigger("focus");
            $("#BackgroundColor").trigger("blur");
            $("#Font").val(data["Font"]);
            $("#TextureId").val(data["TextureId"]);
            $("#addTextureContainer").hide();
            if (data["LogoRightUrl"] != null) {
                $('#LogoRightUrl').val(data["LogoRightUrl"]);
                $('#logoRight').html('<img src="' + data["LogoRightUrl"] + '" />');
                var h = "<a onclick=\"deleteLogoRight('" + data["LogoRightUrl"] + "')\" >Usuń</a>";
                $('#logoRighttDelete').html(h);
            }
            if (data["LogoLeftUrl"] != null) {
                $('#LogoLeftUrl').val(data["LogoLeftUrl"]);
                $('#logoLeft').html('<img src="' + data["LogoLeftUrl"] + '" />');
                var h = "<a onclick=\"deleteLogoLeft('" + data["LogoLeftUrl"] + "')\" >Usuń</a>";
                $('#logoLeftDelete').html(h);
            }
            if (data["LoginBannerUrl"] != null) {
                $('#LoginBannerUrl').val(data["LoginBannerUrl"]);
                $('#LoginBanner').html('<img src="' + data["LoginBannerUrl"] + '" />');
                var h = "<a onclick=\"deleteLoginBanner('" + data["LoginBannerUrl"] + "')\" >Usuń</a>";
                $('#LoginBannerUrlDelete').html(h);
            }
            if (data["PlatformLeftUrl"] != null) {
                $('#PlatformLeftUrl').val(data["PlatformLeftUrl"]);
                $('#PlatformLeft').html('<img src="' + data["PlatformLeftUrl"] + '" />');
                var h = "<a onclick=\"PlatformDeleteLogoLeft('" + data["PlatformLeftUrl"] + "')\" >Usuń</a>";
                $('#PlatformLeftDelete').html(h);
            }
            if (data["PlatformRightUrl"] != null) {
                $('#PlatformRightUrl').val(data["PlatformRightUrl"]);
                $('#PlatformRight').html('<img src="' + data["PlatformRightUrl"] + '" />');
                var h = "<a onclick=\"PlatformDeleteLogoRight('" + data["PlatformRightUrl"] + "')\" >Usuń</a>";
                $('#PlatformRightDelete').html(h);
            }
            if (data["PlatformBannerUrl"] != null) {
                $('#PlatformBannerUrl').val(data["PlatformBannerUrl"]);
                $('#PlatformBanner').html('<img src="' + data["PlatformBannerUrl"] + '" />');
                var h = "<a onclick=\"deletePlatformBanner('" + data["PlatformBannerUrl"] + "')\" >Usuń</a>";
                $('#PlatformBannerUrlDelete').html(h);
            }

            if (data["LoginLayoutType"] != null) {
                $('#LoginLayoutType').val(data["LoginLayoutType"]);
            }
            if (data["PlatformLayoutType"] != null) {
                $('#PlatformLayoutType').val(data["PlatformLayoutType"]);
            }
        });
    }
}